<?php
require_once dirname(__FILE__).'/configs.php';

class UserDao {
    private $db;
    
    public function __construct() {
//         $this->db = new PDO('mysql:host='.DB_MYSQL_HOST. ';port='.DB_MYSQL_PORT . ';dbname=p4p;charset=UTF8', 
//             DB_MYSQL_USER, DB_MYSQL_PASSWORD);
// 	    $this->db->exec("SET NAMES 'utf8'");
    }
    
    public function getUserByLoginname($loginname) {
//         $sql = "select * from user where loginname=:loginname";
//         $exe = $this->db->prepare($sql);
//         $exe->execute(array('loginname'=>$loginname));
//         return $exe->fetch(PDO::FETCH_ASSOC);
        $db_link=mysql_connect('localhost','root','yiqifacai');
        $program_char="utf8";
        mysql_set_charset($program_char, $db_link);
        $charset = mysql_client_encoding ($db_link);
        
        mysql_select_db('p4p');
        $sql = "select * from user where loginname='$loginname'";
        $query = mysql_query($sql);
        $row = mysql_fetch_assoc($query);
        return $row;
    } 
}
?>
